package com.ruyuan.little.project.rocketmq.api.login.producer;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LoginProducerConfiguration {

    @Value("${rocketmq.namesrv.address}")
    private String namesrvAddress;
    @Value("${rocketmq.login.producer.group}")
    private String loginProduceGroup;


    /**
    * @Description:
    * @param
    * @return 登录消息mq的生产者对象
    * @throws
    * @author dakun
    * @date 2021/6/27 11:07
    */
    @Bean(value = "loginMqProducer")
    public DefaultMQProducer loginMqProducer() throws MQClientException{
        DefaultMQProducer producer = new DefaultMQProducer(loginProduceGroup);
        producer.setNamesrvAddr(namesrvAddress);
        producer.start();
        return producer;

    }

}
